diff options
Diffstat (limited to 'app/[lng]/evcp/(evcp)/gtc')
| -rw-r--r-- | app/[lng]/evcp/(evcp)/gtc/[id]/page.tsx | 142 | ||||
| -rw-r--r-- | app/[lng]/evcp/(evcp)/gtc/page.tsx | 69 |
2 files changed, 211 insertions, 0 deletions
diff --git a/app/[lng]/evcp/(evcp)/gtc/[id]/page.tsx b/app/[lng]/evcp/(evcp)/gtc/[id]/page.tsx new file mode 100644 index 00000000..0f783375 --- /dev/null +++ b/app/[lng]/evcp/(evcp)/gtc/[id]/page.tsx @@ -0,0 +1,142 @@ +import * as React from "react" +import { notFound } from "next/navigation" +import { type SearchParams } from "@/types/table" +import { getValidFilters } from "@/lib/data-table" +import { Skeleton } from "@/components/ui/skeleton" +import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton" +import { Shell } from "@/components/shell" +import { InformationButton } from "@/components/information/information-button" + +import { + getGtcClauses, + getUsersForFilter, +} from "@/lib/gtc-contract/gtc-clauses/service" +import { getGtcDocumentById } from "@/lib/gtc-contract/service" +import { searchParamsCache } from "@/lib/gtc-contract/gtc-clauses/validations" +import { GtcClausesPageHeader } from "@/lib/gtc-contract/gtc-clauses/gtc-clauses-page-header" +import { GtcClausesTable } from "@/lib/gtc-contract/gtc-clauses/table/clause-table" + +interface GtcClausesPageProps { + params: Promise<{ id: string }> + searchParams: Promise<SearchParams> +} + +export default async function GtcClausesPage(props: GtcClausesPageProps) { + const params = await props.params + const searchParams = await props.searchParams + const documentId = parseInt(params.id) + + if (isNaN(documentId)) { + notFound() + } + + // 문서 정보 조회 + const document = await getGtcDocumentById(documentId) + if (!document) { + notFound() + } + + const search = searchParamsCache.parse(searchParams) + const validFilters = getValidFilters(search.filters) + + // 병렬로 데이터 조회 + const promises = Promise.all([ + getGtcClauses({ + ...search, + filters: validFilters, + documentId, + }), + getUsersForFilter() + ]) + + return ( + <Shell className="gap-2"> + {/* 헤더 컴포넌트 */} + <GtcClausesPageHeader document={document} /> + + {/* 문서 정보 카드 */} + <div className="rounded-lg border bg-card p-4"> + <div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm"> + <div> + <div className="font-medium text-muted-foreground">최초등록일</div> + <div>{document.createdAt ? new Date(document.createdAt).toLocaleDateString('ko-KR') : '-'}</div> + </div> + <div> + <div className="font-medium text-muted-foreground">최초등록자</div> + <div>{document.createdByName || '-'}</div> + </div> + <div> + <div className="font-medium text-muted-foreground">최종수정일</div> + <div>{document.updatedAt ? new Date(document.updatedAt).toLocaleDateString('ko-KR') : '-'}</div> + </div> + <div> + <div className="font-medium text-muted-foreground">최종수정자</div> + <div>{document.updatedByName || '-'}</div> + </div> + </div> + + {document.editReason && ( + <div className="mt-3 pt-3 border-t"> + <div className="font-medium text-muted-foreground mb-1">최종 편집사유</div> + <div className="text-sm">{document.editReason}</div> + </div> + )} + </div> + + {/* 조항 테이블 */} + <React.Suspense + fallback={ + <DataTableSkeleton + columnCount={8} + searchableColumnCount={2} + filterableColumnCount={3} + cellWidths={["10rem", "15rem", "20rem", "30rem", "12rem", "12rem", "12rem", "8rem"]} + shrinkZero + /> + } + > + <GtcClausesTable + promises={promises} + documentId={documentId} + document={document} + /> + </React.Suspense> + </Shell> + ) +} + +// 메타데이터 생성 +export async function generateMetadata(props: GtcClausesPageProps) { + const params = await props.params + const documentId = parseInt(params.id) + + if (isNaN(documentId)) { + return { + title: "GTC 조항 관리", + } + } + + try { + const document = await getGtcDocumentById(documentId) + + if (!document) { + return { + title: "GTC 조항 관리", + } + } + + const title = `GTC 조항 관리 - ${document.type === "standard" ? "표준" : "프로젝트"} v${document.revision}` + const description = document.project + ? `${document.project.name} (${document.project.code}) 프로젝트의 GTC 조항을 관리합니다.` + : "표준 GTC 조항을 관리합니다." + + return { + title, + description, + } + } catch (error) { + return { + title: "GTC 조항 관리", + } + } +}
\ No newline at end of file diff --git a/app/[lng]/evcp/(evcp)/gtc/page.tsx b/app/[lng]/evcp/(evcp)/gtc/page.tsx new file mode 100644 index 00000000..33c504df --- /dev/null +++ b/app/[lng]/evcp/(evcp)/gtc/page.tsx @@ -0,0 +1,69 @@ +import * as React from "react" +import { type SearchParams } from "@/types/table" +import { getValidFilters } from "@/lib/data-table" +import { Skeleton } from "@/components/ui/skeleton" +import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton" +import { Shell } from "@/components/shell" +import { InformationButton } from "@/components/information/information-button" +import { GtcDocumentsTable } from "@/lib/gtc-contract/status/gtc-contract-table" +import { getGtcDocuments,getProjectsForFilter,getUsersForFilter } from "@/lib/gtc-contract/service" +import { searchParamsCache } from "@/lib/gtc-contract/validations" + +interface GtcPageProps { + searchParams: Promise<SearchParams> +} + +export default async function GtcPage(props: GtcPageProps) { + const searchParams = await props.searchParams + const search = searchParamsCache.parse(searchParams) + const validFilters = getValidFilters(search.filters) + + const promises = Promise.all([ + getGtcDocuments({ + ...search, + filters: validFilters, + }), + getProjectsForFilter(), + getUsersForFilter() + ]) + + return ( + <Shell className="gap-2"> + <div className="flex items-center justify-between space-y-2"> + <div className="flex items-center justify-between space-y-2"> + <div> + <div className="flex items-center gap-2"> + <h2 className="text-2xl font-bold tracking-tight"> + GTC 목록관리 + </h2> + <InformationButton pagePath="evcp/basic-contract-template/gtc" /> + </div> + </div> + </div> + </div> + + <React.Suspense fallback={<Skeleton className="h-7 w-52" />}> + {/* <DateRangePicker + triggerSize="sm" + triggerClassName="ml-auto w-56 sm:w-60" + align="end" + shallow={false} + /> */} + </React.Suspense> + + <React.Suspense + fallback={ + <DataTableSkeleton + columnCount={6} + searchableColumnCount={1} + filterableColumnCount={2} + cellWidths={["10rem", "40rem", "12rem", "12rem", "8rem", "8rem"]} + shrinkZero + /> + } + > + <GtcDocumentsTable promises={promises} /> + </React.Suspense> + </Shell> + ) +}
\ No newline at end of file |
